package cn.datawin.common.state.template.condition;

import cn.datawin.common.state.StateMachineUtil;
import cn.datawin.common.state.entity.BaseBasket;
import org.squirrelframework.foundation.fsm.Condition;


/**
 * 你还在吗的条件类
 * Created by hyygavin on 2018/1/13.
 */
public class LocalBackCondition implements Condition<Object> {

    private String prefixName;

    public LocalBackCondition(String prefixName) {
        this.prefixName = prefixName;
    }

    @Override
    public boolean isSatisfied(Object obj) {
        BaseBasket basket = (BaseBasket) obj;
        basket.setLocalBackEvent(StateMachineUtil.event(name(),prefixName));
        return true;
    }

    @Override
    public String name() {
        return prefixName+"conditionEnd";
    }
}
